<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 18/11/14
 * Time: 1:56 PM
 */

class Admin_Utility_Cache_Controller extends Admin_Controller
{

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
        $this->theme->set_theme("admin");
        $this->theme->set_layout("default");
    }


    public function get_index()
    {
        $this->theme->title("UTILITY : CACHE");
        $data['title'] = 'Cache Management';
        return $this->theme->render('admin::utility.cache',$data);
    }

    public function post_index()
    {
        $cache_path = path('storage').'cache/';
        File::cleandir($cache_path);
        return Redirect::back()->with('message', '<div class="alert alert-info">All Cleared</div>');
    }

    public function get_delete($cache_file){



        switch ($cache_file) {
            case 'settings':
                Caches::clear('settings');
                break;

            case 'categories':
                Caches::clear('categories');
                break;

            case 'locations':
                Caches::clear('locations');
                break;

            case 'recent':
                Caches::clear('recent');
                break;
                break;

            case 'featured':
                Caches::clear('featured');
                break;
        }

        return Redirect::to(URL::base().'/admin/utility/cache')->with('message', '<div class="alert alert-info">Cache Cleared</div>');
    }




}